 /**********************
 * Matthew Tanner
 * tannerm.onid.orst.edu
 * CS362
 * Assignment #3 cardtest4.c
 * Tests the salvager card functionality in dominion.c
 * Code is in cardEffect function
 ***********************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "rngs.h"
#include "tests.h"

//set minimum required variables

void cardtest4(){

	struct gameState g;
	int players = 2;
	int k[10] = {adventurer, council_room, sea_hag, gardens, mine, remodel, smithy, village, baron, great_hall};
	int seed = 100;
	int res, trashedValue, player, coins;
	int bonus = 0;

	//initialize game, check initial # of cards for reference
	res = initializeGame(players, k, seed, &g);
	player = whoseTurn(&g);
	coins = g.coins;

	printf("Testing salvager card (card effect switch case):\n");
	printf("Number of cards in hand: %d, coins: %d, buys: %d\n", numHandCards(&g),
		coins, g.numBuys);
	
	// First Condition is no card chosen to trash (+1 buy only)
	printf("Playing salvager card with no card trashed\n");
	res = cardEffect(salvager, 0, 0, 0, &g, 5, &bonus);
	printf("Number of cards expected: 4, actual: %d\n", numHandCards(&g));
	assert(numHandCards(&g) == 4);
	printf("Number of buys expected: 2, actual: %d\n", g.numBuys);
	assert(g.numBuys == 2);
	printf("Coins expected: %d, actual: %d\n", coins, g.coins);
	assert(g.coins == coins);	

	// Second condition is choosing to trash a card
	printf("Playing salvager card, trashing card in handPos=1\n");
	trashedValue = getCost(handCard(1, &g));
	coins += trashedValue;
	res = cardEffect(salvager, 1, 0, 0, &g, 5, &bonus);

	printf("Number of cards expected: 2, actual: %d\n", numHandCards(&g));
	assert(numHandCards(&g) == 2);
	printf("Number of buys expected: 3, actual: %d\n", g.numBuys);
	assert(g.numBuys == 3);
	printf("Coins expected: %d, actual: %d\n", coins, g.coins);
	assert(g.coins == coins);
}



